package uk.co.q3c.deplan.client.ui.commands;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import uk.co.q3c.deplan.client.Orchestrator;
import uk.co.q3c.deplan.client.domain.DomainKind;
import uk.co.q3c.deplan.client.domain.task.BaseTask;
import uk.co.q3c.deplan.client.ui.command.AddNewSubTaskCommand;

@Test
public class AddNewSubTaskCommand_UT extends Command_UT {
	AddNewSubTaskCommand cmd;
	BaseTask parentTask;

	@BeforeMethod
	protected void beforeMethod() {
		cmd = new AddNewSubTaskCommand();
		parentTask = new BaseTask(Orchestrator.serviceFactory());
	}

	@Test(expectedExceptions = { RuntimeException.class })
	public void noParentTask() {
		cmd.execute();
	}

	@Test(expectedExceptions = { RuntimeException.class })
	public void noTaskType() {
		cmd.setParentTask(parentTask);
		cmd.execute();
	}

	/**
	 * test suspended
	 */
	@Test(enabled = false)
	public void testIT() {
		cmd.setParentTask(parentTask);
		cmd.setTaskType(DomainKind.AbstractTask);
		cmd.execute();
		Assert.assertEquals(parentTask.subTaskCount(), 1);
	}
}